﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static CheccCoverplateCulvertAssemble.Common.CommonEnum;

namespace CheccCoverplateCulvertAssemble.Common.Total
{
    /// <summary>
    /// 总体
    /// </summary>
    public class CommomTotal : MyNotifyPropertyChanged
    {
        public CommomTotal()
        {
        }

        public CommomTotal(string generalDiagram, List<AlignmentProperty> selectAlignments, LineElement selectLine, string culvertStackMark, int crossingAngle, double precision,  double slope, double elevation, double fillValue, EntranceToCave entranceToCave)
        {
            GeneralDiagram = generalDiagram;
            SelectAlignments = selectAlignments;
            SelectLine = selectLine;
            CulvertStackMark = culvertStackMark;
            CrossingAngle = crossingAngle;
            Precision = precision;

            Slope = slope;
            Elevation = elevation;
            FillValue = fillValue;
            EntranceToCave = entranceToCave;
        }
        private List<AlignmentProperty> _selectAlignments = new List<AlignmentProperty>();
        private LineElement _selectLine;
        private string _culvertStackMark;
        private int _crossingAngle;
        private double _precision;
        private string _clearSpanHeadroom;
        private double _slope;
        private double _elevation;
        private string _coverPlateType;
        private string _baseType;
        private double _fillValue;
        private double _leftFillValue;
        private double _rightFillValue;
        private double _leftLength;
        private double _rightLength;
        private double _leftAngle;
        private double _rightAngle;
        private EntranceToCave _entranceToCave = new EntranceToCave();
        private string _generalDiagram;
        private string _isUse;

        /// <summary>
        /// 是否采用涵洞通用图
        /// </summary>
        public string WhetherGeneralDiagram
        {
            get
            {
                return _isUse;
            }
            set
            {
                if (value == _isUse)
                    return;
                _isUse = value;
                NotifyPropertyChanged(() => WhetherGeneralDiagram);
            }
        }


        /// <summary>
        /// 涵洞通用图
        /// </summary>
        public string GeneralDiagram
        {
            get
            {
                return _generalDiagram;
            }
            set
            {
                if (value == _generalDiagram)
                    return;
                _generalDiagram = value;
                NotifyPropertyChanged(() => GeneralDiagram);
            }
        }


        /// <summary>
        /// 选择的所有路线
        /// </summary>
       
        public List<AlignmentProperty> SelectAlignments
        {
            get
            {
                return _selectAlignments;
            }
            set
            {
                if (value == _selectAlignments)
                    return;
                _selectAlignments = value;
                NotifyPropertyChanged(() => SelectAlignments);
            }
        }

        /// <summary>
        /// 选择的路线交线
        /// </summary>
        [JsonIgnore]
        public LineElement SelectLine
        {
            get
            {
                return _selectLine;
            }
            set
            {
                if (value == _selectLine)
                    return;
                _selectLine = value;
                NotifyPropertyChanged(() => SelectLine);
            }
        }

        /// <summary>
        /// 涵洞桩号
        /// </summary>
        public string CulvertStackMark
        {
            get
            {
                return _culvertStackMark;
            }
            set
            {
                if (value == _culvertStackMark)
                    return;
                _culvertStackMark = value;
                NotifyPropertyChanged(() => CulvertStackMark);
            }
        }

        /// <summary>
        /// 涵洞交角
        /// </summary>
        public int CrossingAngle
        {
            get
            {
                return _crossingAngle;
            }
            set
            {
                if (value == _crossingAngle)
                    return;
                _crossingAngle = value;
                NotifyPropertyChanged(() => CrossingAngle);
            }
        }

        /// <summary>
        /// 桩号精度
        /// </summary>
        public double Precision
        {
            get
            {
                return _precision;
            }
            set
            {
                if (value == _precision)
                    return;
                _precision = value;
                NotifyPropertyChanged(() => Precision);
            }
        }

        /// <summary>
        /// 净跨净高
        /// </summary>
        public string ClearSpanHeadroom
        {
            get
            {
                return _clearSpanHeadroom;
            }
            set
            {
                if (value == _clearSpanHeadroom)
                    return;
                _clearSpanHeadroom = value;
                NotifyPropertyChanged(() => ClearSpanHeadroom);
            }
        }

        /// <summary>
        /// 涵底坡度
        /// </summary>
        public double Slope
        {
            get
            {
                return _slope;
            }
            set
            {
                if (value == _slope)
                    return;
                _slope = value;
                NotifyPropertyChanged(() => Slope);
            }
        }

        /// <summary>
        /// 涵底高程
        /// </summary>
        public double Elevation
        {
            get
            {
                return _elevation;
            }
            set
            {
                if (value == _elevation)
                    return;
                _elevation = value;
                NotifyPropertyChanged(() => Elevation);
            }
        }
        /// <summary>
        /// 盖板型式
        /// </summary>
        public string CoverPlateType
        {
            get
            {
                return _coverPlateType;
            }
            set
            {
                if (value == _coverPlateType)
                    return;
                _coverPlateType = value;
                NotifyPropertyChanged(() => CoverPlateType);
            }
        }

        /// <summary>
        /// 基础类型
        /// </summary>
        public string BaseType
        {
            get
            {
                return _baseType;
            }
            set
            {
                if (value == _baseType)
                    return;
                _baseType = value;
                NotifyPropertyChanged(() => BaseType);
            }
        }

        /// <summary>
        /// 填土值
        /// </summary>
        public double FillValue
        {
            get
            {
                return _fillValue;
            }
            set
            {
                if (value == _fillValue)
                    return;
                _fillValue = value;
                NotifyPropertyChanged(() => FillValue);
            }
        }

        /// <summary>
        /// 左侧路肩填土值
        /// </summary>
        public double LeftFillValue
        {
            get
            {
                return _leftFillValue;
            }
            set
            {
                if (value == _leftFillValue)
                    return;
                _leftFillValue = value;
                NotifyPropertyChanged(() => LeftFillValue);
            }
        }
        /// <summary>
        /// 右侧路肩填土值
        /// </summary>
        public double RightFillValue
        {
            get
            {
                return _rightFillValue;
            }
            set
            {
                if (value == _rightFillValue)
                    return;
                _rightFillValue = value;
                NotifyPropertyChanged(() => RightFillValue);
            }
        }
        /// <summary>
        /// 左涵长
        /// </summary>
        public double LeftLength
        {
            get
            {
                return _leftLength;
            }
            set
            {
                if (value == _leftLength)
                    return;
                _leftLength = value;
                NotifyPropertyChanged(() => LeftLength);
            }
        }
        /// <summary>
        /// 右涵长
        /// </summary>
        public double RightLength
        {
            get
            {
                return _rightLength;
            }
            set
            {
                if (value == _rightLength)
                    return;
                _rightLength = value;
                NotifyPropertyChanged(() => RightLength);
            }
        }
        /// <summary>
        /// 左洞口交角
        /// </summary>
        public double LeftAngle
        {
            get
            {
                return _leftAngle;
            }
            set
            {
                if (value == _leftAngle)
                    return;
                _leftAngle = value;
                NotifyPropertyChanged(() => LeftAngle);
            }
        }
        /// <summary>
        /// 右洞口交角
        /// </summary>
        public double RightAngle
        {
            get
            {
                return _rightAngle;
            }
            set
            {
                if (value == _rightAngle)
                    return;
                _rightAngle = value;
                NotifyPropertyChanged(() => RightAngle);
            }
        }
        /// <summary>
        /// 洞口构造
        /// </summary>
        public EntranceToCave EntranceToCave
        {
            get
            {
                return _entranceToCave;
            }
            set
            {
                if (value == _entranceToCave)
                    return;
                _entranceToCave = value;
                NotifyPropertyChanged(() => EntranceToCave);
            }
        }

        public double IntersectionPointDisAlong { get; set; }
    }
    /// <summary>
    /// 洞口构造
    /// </summary>
    public class EntranceToCave : MyNotifyPropertyChanged
    {
        private EntranceToCaveBase _left = new EntranceToCaveBase();
        private EntranceToCaveBase _right = new EntranceToCaveBase();
        /// <summary>
        /// 左洞口
        /// </summary>
        public EntranceToCaveBase Left
        {
            get
            {
                return _left;
            }
            set
            {
                if (value == _left)
                    return;
                _left = value;
                NotifyPropertyChanged(() => Left);
            }
        }

        /// <summary>
        /// 右洞口
        /// </summary>
        public EntranceToCaveBase Right
        {
            get
            {
                return _right;
            }
            set
            {
                if (value == _right)
                    return;
                _right = value;
                NotifyPropertyChanged(() => Right);
            }
        }
    }

    /// <summary>
    /// 锥坡信息
    /// </summary>
    public class ConicalSlopeIndo : EntranceToCaveBase
    {
        public ConicalSlopeIndo()
        {
        }


        public ConicalSlopeIndo(double slopeRatio, double baseDepth, string isEndWall, string isCapStone) : base(isEndWall, isCapStone)
        {
            SlopeRatio = slopeRatio;
            BaseDepth = baseDepth;
        }

        private EntranceCaveType _entranceCaveType = EntranceCaveType.ConicalSlope;
        private double _slopeRatio;
        private double _baseDepth;

        public EntranceCaveType EntranceCaveType
        {
            get
            {
                return _entranceCaveType;
            }
            set
            {
                if (value == _entranceCaveType)
                    return;
                _entranceCaveType = value;
                NotifyPropertyChanged(() => EntranceCaveType);
            }
        }

        /// <summary>
        /// 断面坡比
        /// </summary>
        public double SlopeRatio
        {
            get
            {
                return _slopeRatio;
            }
            set
            {
                if (value == _slopeRatio)
                    return;
                _slopeRatio = value;
                NotifyPropertyChanged(() => SlopeRatio);
            }
        }

        /// <summary>
        /// 基础深度
        /// </summary>
        public double BaseDepth
        {
            get
            {
                return _baseDepth;
            }
            set
            {
                if (value == _baseDepth)
                    return;
                _baseDepth = value;
                NotifyPropertyChanged(() => BaseDepth);
            }
        }
    }

    /// <summary>
    /// 八字墙洞口信息
    /// </summary>
    public class AliformWallInfo : EntranceToCaveBase
    {
        public AliformWallInfo()
        {
        }

        public AliformWallInfo(double baseBurialDepth, double edge, string isEndWall, string isCapStone) : base(isEndWall, isCapStone)
        {
            BaseBurialDepth = baseBurialDepth;
            Edge = edge;
        }

        private double _baseBurialDepth;
        private double _edge;

        public EntranceCaveType EntranceCaveType { get; } = EntranceCaveType.AliformWall;

        /// <summary>
        /// 基础埋深
        /// </summary>
        public double BaseBurialDepth
        {
            get
            {
                return _baseBurialDepth;
            }
            set
            {
                if (value == _baseBurialDepth)
                    return;
                _baseBurialDepth = value;
                NotifyPropertyChanged(() => BaseBurialDepth);
            }
        }

        /// <summary>
        /// 内侧襟边
        /// </summary>
        public double Edge
        {
            get
            {
                return _edge;
            }
            set
            {
                if (value == _edge)
                    return;
                _edge = value;
                NotifyPropertyChanged(() => Edge);
            }
        }
    }


    public class EntranceToCaveBase : MyNotifyPropertyChanged
    {
        public EntranceToCaveBase()
        {
        }

        public EntranceToCaveBase(string isEndWall, string isCapStone)
        {
            IsEndWall = isEndWall;
            IsCapStone = isCapStone;
        }
        private string _isEndWall;
        private string _isCapStone;
        private string _type;


        /// <summary>
        /// 洞口类型
        /// </summary>
        public string Type
        {
            get
            {
                return _type;
            }
            set
            {
                if (value == _type)
                    return;
                _type = value;
                NotifyPropertyChanged(() => Type);
            }
        }

        public string IsEndWall
        {
            get
            {
                return _isEndWall;
            }
            set
            {
                if (value == _isEndWall)
                    return;
                _isEndWall = value;
                NotifyPropertyChanged(() => IsEndWall);
            }
        }

        public string IsCapStone
        {
            get
            {
                return _isCapStone;
            }
            set
            {
                if (value == _isCapStone)
                    return;
                _isCapStone = value;
                NotifyPropertyChanged(() => IsCapStone);
            }
        }
    }
}
